#ifndef __SHADOW_CASTER_ENTITY_HANDLER_HPP__
#define __SHADOW_CASTER_ENTITY_HANDLER_HPP__

////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include "BaseEntityHandler.hpp"

class ShadowCasterEntityHandler : public BaseEntityHandler
{
public:
    ////////////////////////////////////////////////////////////
    /// Constructor
    ///
    ////////////////////////////////////////////////////////////
                            ShadowCasterEntityHandler();
    ////////////////////////////////////////////////////////////
    /// Copy Constructor
    ///
    /// \param _Copy :      Handler to copy from
    ///
    ////////////////////////////////////////////////////////////
                            ShadowCasterEntityHandler( const ShadowCasterEntityHandler& _Copy );
    
    ////////////////////////////////////////////////////////////
    /// Init the handler from properties
    /// BaseObjectHandler::InitFromGrid need to be called AFTER the specialized class
    ///
    /// \param _pPropertyGrid :      Grid where infos are stored
    ///
    /// \return Whether the init was successful or not
    ///
    ////////////////////////////////////////////////////////////
    virtual bool            InitFromGrid( wxPropertyGrid* _pPropertyGrid );
    
    ////////////////////////////////////////////////////////////
    /// Init the handler from an XMLElement
    /// BaseObjectHandler::InitFromXML need to be called AFTER the specialized class
    ///
    /// \param _pElement :           XML Element with info
    /// \param _ProjectPath :        Path to the project
    ///
    /// \return Whether the init was successful or not
    ///
    ////////////////////////////////////////////////////////////
    virtual bool            InitFromXML( tinyxml2::XMLElement* _pElement, const wxString& _ProjectPath );
    
    ////////////////////////////////////////////////////////////
    /// Return the value of a property
    ///
    /// \param _PropertyName :      Name of the property
    ///
    /// \return The value as a string
    ///
    ////////////////////////////////////////////////////////////
    virtual wxString        GetValueAsString( const wxString& _PropertyName ) const;
    
    ////////////////////////////////////////////////////////////
    /// Return the value of a property with a choice
    ///
    /// \param _pChoiceProperty :    Property we want the choice
    ///
    /// \return The value of the choice
    ///
    ////////////////////////////////////////////////////////////
    virtual int             GetChoiceValue( wxPGProperty* _pChoiceProperty );
    
    ////////////////////////////////////////////////////////////
    /// Handle the change of a property and apply it to the object
    ///
    /// \param _pPropertyGrid :      The property grid
    /// \param _pChangedProperty :   Property that has been changed
    ///
    /// \return Whether the object has been changed or not
    ///
    ////////////////////////////////////////////////////////////
    virtual bool            OnPropertyChanged( wxPropertyGrid* _pPropertyGrid, wxPGProperty* _pChangedProperty );
    
    ////////////////////////////////////////////////////////////
    /// Handle the double click on a property
    ///
    /// \param _pPropertyGrid :      The property grid
    /// \param _pChangedProperty :   Property that has been changed
    ///
    /// \return Whether the object has been changed or not
    ///
    ////////////////////////////////////////////////////////////
    virtual bool            OnPropertyDoubleClick( wxPropertyGrid* _pPropertyGrid, wxPGProperty* _pChangedProperty );
    
    ////////////////////////////////////////////////////////////
    /// Get the name of the object handler
    ///
    /// \return the name of the object handler
    ///
    ////////////////////////////////////////////////////////////
    virtual wxString        GetName() const;

    CREATE_CLONE_FUNC(ShadowCasterEntityHandler, BaseXMLObject)

protected:
    enum eHullType {
        eHull_NoHull = 0,
        eHull_Circle = 1,
        eHull_Convex = 2,
        eHull_Texture = 3
    };
    
    eHullType               m_eCurrentHull;
    BaseObjectHandler*      m_pHullHandler;

    ////////////////////////////////////////////////////////////
    /// Changing the type of Hull
    ///
    /// \param _type :   New type of Hull
    /// \param _pPropertyGrid :      The property grid
    ///
    ////////////////////////////////////////////////////////////
    void                    ChangeHull( eHullType _type, wxPropertyGrid* _pPropertyGrid );

    ////////////////////////////////////////////////////////////
    /// Create an XML string with the value of the object
    ///
    /// \param _ProjectPath :   Path to the project
    ///
    /// \return the XML String
    ///
    ////////////////////////////////////////////////////////////
    virtual wxString        InnerXMLString( const wxString& _ProjectPath = wxEmptyString, const wxString& _Tab = wxT( "\t" ) ) const;
};

////////////////////////////////////////////////////////////
/// Get the name of the object handler
////////////////////////////////////////////////////////////
inline wxString ShadowCasterEntityHandler::GetName() const {
    return "Shadow Caster Entity";
}

#endif // __SHADOW_CASTER_ENTITY_HANDLER_HPP__